let app = new Vue({
    el: "#app",
    data() {
        return {
			// 添加、编辑标识
			teamFormVisible:false,
			teamForm: {
                memberid: null
            },
        }
    },
	methods: {
		// 确认
		async cofirm(){
            this.$refs.teamForm.validate(async valid => {
                if (valid){
					// 显示加载框
					const loading = this.$loading(LOAD_STYLE);
					try {
						let res = null;
						// 添加成员
						res = await axios.put('api/team/add', this.teamForm);
						if (res.code === 200) {
							this.getallmember();
							this.teamFormVisible = false
						}else {
							this.$message.error(res.message);
						}					

					}catch (e) {
						this.$message.error('添加成员出错！', e.message);
					}
					// 关闭加载框
					loading.close();
                }
            })			
		},
		// 显示所有成员 
		async getallmember() {
			// 显示加载框
			const loading = this.$loading(LOAD_STYLE);
			try {
				let res = await axios.post('api/team/getallmember');
				if (res.code === 200) {
					this.$message.success(res.message);
				}else {
					this.$message.error(res.message);
				}
			}catch (e) {
				this.$message.error('所有成员取得出错！', e.message);
			}
			
			// 关闭加载框
			loading.close();
		},
	},
	async mounted() {
		this.getallmember()
	}

});	